<template>
  <div class="container_edit">
    <div class="header">
      <p>客服电话</p>
    </div>
    <div class="main">
      <el-form
        :model="params"
        :rules="rules"
        ref="user"
        label-width="150px"
        class=""
      >
        <el-form-item
          label=""
          prop="path"
        >
          <el-input v-model="params.path"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            @click="handleSave('user')"
          >保存</el-button>
          <el-button @click="params.path = ''">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

  </div>
</template>

<script>
  let CONSTANT = require("../../constant/constant.js");
  let common = require("../../common.js");
  export default {
    data() {
      return {
        upLoadUrl: "",
        imageUrl: "",
        params: {
          path: "",
        },
        rules: {
          path: [
            { required: true, message: "请填写客服电话", trigger: "blur" }
          ]
        },
      };
    },
    mounted() {
      this.getInfo();
    },
    components: {
      "bg-editor": () => import("../common/bg-editor.vue")
    },
    methods: {
      getInfo: function() {
        let url = CONSTANT.URL.SYSTEM.telDetail;
        common.get(url,'', res => {
          if (res.status == 200) {
            let data = res.data.bussData;
            this.params.path = data
          }
        });
      },
      handleSave: function(formName) {
        this.$refs[formName].validate(valid => {
          if (valid) {
            let url = CONSTANT.URL.SYSTEM.telSave;
            common.put(url, '', JSON.stringify({value: this.params.path}), res => {
              if (res.status == 200) {
                this.$message({
                  type: "success",
                  message: "保存成功！"
                });
              } else {
                this.$message({
                  type: "warning",
                  message: res.msg
                });
              }
            });
          } else {
            console.log("error submit!!");
            return false;
          }
        });
      },
    }
  };
</script>
<style lang="scss" scoped>
  .table-content {
    width: 500px;
    .table-item {
      position: relative;
      border: 1px solid #dcdfe6;
      i {
        position: absolute;
        right: -30px;
        top: 20px;
        cursor: pointer;
        font-size: 16px;
      }
      &:first-child {
        background-color: #409eff;
        color: #fff;
        border-right: 0px solid #dcdfe6;
        .table-list {
          padding: 0;
        }
      }

      .table-list {
        flex: 2;
        text-align: center;
        padding: 5px 0;
        .el-input {
          height: 70% !important;
          width: 90%;
        }
        &:first-child {
          flex: 3;
          border-right: 1px solid #dcdfe6;
        }
      }
    }
  }
</style>
